from sqlalchemy import Column, String, DECIMAL, Boolean, DateTime
from sqlalchemy.dialects.mysql import TINYINT, BIGINT
from pydantic import BaseModel
from server.model import BaseOrm
from datetime import datetime
from server import db


class FieldStatus:
    Not = 0
    Serv = 1


class FieldCreate(BaseModel):
    name: str
    address: str
    open_time: datetime
    close_time: datetime


class FieldSchema(FieldCreate):
    id: int

    class Config:
        orm_mode = True


# 场地
class Field(BaseOrm):
    __tablename__ = 'field'
    gym_id = Column(BIGINT(20, unsigned=True), nullable=False, index=True, comment="球馆id")
    name = Column(String(64), nullable=False, server_default="", comment="名称")
    status = Column(TINYINT(unsigned=True), nullable=False, server_default="0", comment="状态: 0:正常 1:未开放")


db.create_all()
